﻿
Imports osi.root.constants
Imports lock_t = osi.root.lock.slimlock.monitorlock

Namespace error_handle
    Public Class locked_writer(Of T As ierror_writer)
        Implements ierror_writer
        Public ReadOnly writer As T = Nothing
        Private l As lock_t

        Public Sub New(ByVal writer As T)
            assert(Not writer Is Nothing)
            Me.writer = writer
        End Sub

        Public Sub write(ByVal error_type As error_type, ByVal s As String) Implements ierror_writer.write
            l.locked(Sub() writer.write(error_type, s))
        End Sub

        Public Function [select](ByVal error_type As error_type,
                                 ByVal error_type_char As Char) As Boolean Implements ierror_writer.select
            Return do_(Function() writer.select(error_type, error_type_char), False)
        End Function
    End Class
End Namespace
